<template>
    <Huangheader/>
  <div class="page">
    <div class="shop-detail" v-if="shopData">
      <div class="content">
        <!-- 左侧文字区域 -->
        <div class="shop-info">
          <h2 class="shop-name">{{ shopData.name }}</h2>

          <div class="rating-row">
            <div class="stars">
              <span v-for="n in 5" :key="n" class="star">
                {{ n <= Math.round(shopData.rating) ? '★' : '☆' }}
              </span>
            </div>
            <span class="rating highlight">{{ shopData.rating }}</span>
            <span class="reviews">{{ shopData.reviews }}条</span>
            <span class="price">￥{{ shopData.price_per_person }}/人</span>
          </div>

          <p class="cuisine">{{ shopData.categories.join(' / ') }}</p>
          <div class="divider"></div>

          <div class="score-detail">
            <span>口味 {{ shopData.taste ?? 4.5 }}</span>
            <span>环境 {{ shopData.environment ?? 4.8 }}</span>
            <span>服务 {{ shopData.service ?? 4.4 }}</span>
          </div>

          <div class="badge-row">
            <span class="badge">点评榜单</span>
            <span class="tag">静安区东南亚菜热门榜·第3名</span>
          </div>

          <div class="divider"></div>

          <div class="status">
            <strong>营业中</strong> 11:30 - 23:00
          </div>

          <div class="tag-row">
            <span>有宝宝椅</span>
            <span>有无障碍设施</span>
            <span>有包间</span>
          </div>

          <div class="divider"></div>

          <div class="address-contact-row">
            <div class="left-address">
              <div class="addr">
                <span class="icon">📍</span>
                南京西路1649号静安公园内
              </div>
              <div class="subway">距地铁2/7号线静安寺地铁站2号口230m</div>
            </div>

            <div class="divider-vertical-thin"></div>

            <div class="right-contact">
              <span class="icon">📱</span>
              <span class="btn">到店</span>
              <span class="icon">📞</span>
            </div>
          </div>

          <div class="divider"></div>

          <div class="actions">
            <div class="action">
              <span class="dot">热订</span>
              <button class="btn-green">订座</button>
              <div class="visit">有44253人访问</div>
            </div>

            <div class="divider-vertical"></div>

            <div class="action">
              <span class="icon">🐤</span>
              <span class="btn-yellow">外卖</span>
              <span class="app-link">App内查看更多...</span>
            </div>
          </div>
        </div>

        <!-- 右侧图片区域 -->
        <div class="image-box">
          <img :src="shopData.additional_info" alt="店铺图片" class="shop-image" />
        </div>
      </div>
    </div>

    <div v-else class="loading">加载中...</div>
    <Huangmenu/>
    <div class="comments-container">
      <HuangComments/>
    </div>
    <div class="box1">  <HuangContent/></div>
  </div>
  <Huangback/>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import axios from 'axios'
import Huangmenu from '../components/Huangmenu.vue'
import HuangComments from '../components/HuangComments.vue'

const props = defineProps({
  id: {
    type: String,
    required: true
  }
})

const shopData = ref(null)

onMounted(async () => {
  try {
    const response = await axios.get(`/Huanglist2/${props.id}`)
    shopData.value = response.data
  } catch (error) {
    console.error('获取店铺信息失败:', error)
  }
})
</script>

<style scoped>
.box1{
 max-width: 1180px;
  margin: 0 auto;         /* 让容器本身居中 */
  text-align: center;     /* 让内部的文本或内联元素居中 */
  display: flex;
  justify-content: center; /* 让 flex 子项水平居中 */
  align-items: center;     /* 让 flex 子项垂直居中 */
}
/* 页面整体背景 */
.page {
  background-color: #f5f5f5;
  min-height: 100vh;
  padding: 24px;
}

/* 卡片主体 */
.shop-detail {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  font-family: "Helvetica Neue", Helvetica, sans-serif;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.shop-info {
  flex: 1;
  padding-right: 32px;
  font-size: 14px;
  color: #333;
}

.shop-name {
  font-size: 20px;
  font-weight: bold;
}

.rating-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}

.stars {
  display: flex;
}

.star {
  color: #FFD700;
  font-size: 16px;
}

.highlight {
  color: #f63;
  font-weight: bold;
}

.cuisine {
  color: #888;
}

.divider {
  height: 1px;
  background: #eee;
  margin: 10px 0;
}

.score-detail {
  display: flex;
  gap: 16px;
  color: #444;
  font-size: 13px;
  margin-bottom: 8px;
}

.badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  background: #f5e2c8;
  padding: 2px 6px;
  font-weight: bold;
  font-size: 13px;
}

.tag {
  background: #f9f1e4;
  padding: 2px 6px;
  font-size: 12px;
  color: #b88b55;
}

.status {
  font-weight: bold;
  color: #333;
  margin-top: 8px;
}

.tag-row {
  display: flex;
  gap: 12px;
  font-size: 13px;
  color: #666;
  margin: 8px 0;
}

.address-contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
  margin-bottom: 10px;
}

.left-address {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #444;
}

.addr {
  display: flex;
  align-items: center;
  gap: 4px;
}

.subway {
  color: #888;
  font-size: 12px;
  margin-top: 4px;
}

.right-contact {
  display: flex;
  align-items: center;
  gap: 12px;
}

.divider-vertical-thin {
  width: 1px;
  height: 40px;
  background: #eee;
  margin: 0 10px;
}

.actions {
  display: flex;
  align-items: center;
  margin-top: 12px;
  gap: 20px;
}

.action {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.btn-green {
  background: #4caf50;
  color: white;
  padding: 2px 10px;
  border: none;
  border-radius: 12px;
  font-size: 13px;
}

.btn-yellow {
  background: #ffeb3b;
  color: #333;
  padding: 2px 10px;
  border: none;
  border-radius: 12px;
  font-size: 13px;
}

.dot {
  background: red;
  color: white;
  padding: 0 5px;
  font-size: 12px;
  border-radius: 8px;
}

.visit {
  font-size: 12px;
  color: #888;
}

.app-link {
  color: #999;
  font-size: 12px;
}

.divider-vertical {
  width: 1px;
  height: 40px;
  background: #eee;
  margin: 0 10px;
}

.image-box {
  flex: 1;
  display: flex;
  justify-content: center;
}

.shop-image {
  width: 100%;
  max-width: 420px;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.loading {
  text-align: center;
  font-size: 16px;
  padding: 40px;
}

.comments-container {
  max-width: 1180px;
  margin: 20px auto;
  padding: 0 20px;
}
</style>
